package com.spring.demo5.eg2;

import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;

/**
 * @author vhans
 */
public class ConditionTest {

    @Test
    public void test() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfig3.class);
        Map<String, IService> serviceMap = context.getBeansOfType(IService.class);
        // 当service1注册后，service2不被注册
        serviceMap.forEach((beanName, bean) -> {
            System.out.println(beanName + "->" + bean);
        });
    }
}
